<template>
  <view>
    <uni-list v-if="AnnouncementInfo.length>0">
      <uni-list-item :to="'/my_pkg/notice_item/notice_item?infoItem='+JSON.stringify(item)" link="navigateTo" v-for="(item,index) in AnnouncementInfo" :key="index">
        <template v-slot:header>         
            <view class="ellipsis">{{item.announcementContent}}</view>         
        </template>
        <template v-slot:footer>
           <view>
            <view class="time">{{item.createTime.split(' ')[0]}}</view>
           </view>
        </template>
      </uni-list-item>
    </uni-list>
    <view v-else class="nohave">暂无公告</view>
  </view>
</template>
<script setup>
import { onShow } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { http } from '../../utils/http';
import { useMemberStore } from '../../stores';
const store=useMemberStore()
onShow(()=>{
  getAnnouncementInfo()
})
// 获取通告
const AnnouncementInfo=ref([])
const getAnnouncementInfo=async()=>{
  const {data}=await http({
    url:'/GetAnnouncementInfo',
    method:'post',
    data:{
      ...store.requestData
    }
  })
 if(data&&data.announcementDatas.length>0){
  AnnouncementInfo.value= data.announcementDatas.sort((a,b)=>b.sysAnnouncementSerials-a.sysAnnouncementSerials)
 }

}
</script>
<style scoped>
.time{
  font-size: 30rpx;
  height: 100%;
  display: flex;
  align-items: center;
}
.ellipsis{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300rpx;
}
.nohave{
  margin-top: 20rpx;
  text-align: center;
}
</style>